#include <stdio.h>
#include <assert.h>

int removeElement(int* nums, int numsSize, int val)
{
    assert(nums);
    int count1 = 0;
    for (int i = 0; i < numsSize; i++)
    {
        if (nums[i] == val)
            count1++;
    }
    int sz = numsSize;
    int count = numsSize;
    while (count1)
    {
        for (int i = 0; i < sz; i++)
        {
            if (nums[i] == val)
            {
                for (int j = i; j < sz - 1; j++)
                {
                    nums[j] = nums[j + 1];
                }
                count -= 1;
                sz -= 1;
                count1--;
            }
        }
    }

    
   /* for (int i = 0; i < sz; i++)
    {
        if (nums[i] == val)
        {
            removeElement(nums, sz, val);
        }
    }*/
    return count;
}

int main()
{
    int arr[] = { 0,1,2,2,3,0,4,2 };
    int sz = sizeof(arr) / sizeof(arr[0]);
    int k = removeElement(arr, sz, 2);
    int i = 0;
    for (i = 0; i < k; i++)
    {
        printf("%d ", arr[i]);
    }
    return 0;
}